
#import <Cocoa/Cocoa.h>
#import <ApplicationServices/ApplicationServices.h>

#import "UDPClient.h"

typedef enum _Xentry
{
    left    = 1,
    right   = 2
} XEntry;

@interface MouseAndCatAppDelegate : NSObject <NSApplicationDelegate, InputEventDelegate> 
{
   @private
    NSWindow *window;
    NSPersistentStoreCoordinator *__persistentStoreCoordinator;
    NSManagedObjectModel *__managedObjectModel;
    NSManagedObjectContext *__managedObjectContext;
    NSThread * _serverThread;
    NSThread * _clientThread;
    NSThread * _mouseTrackThread;
    XEntry _xEntry;
    BOOL _beSlave;
    BOOL _mouseDown;
    UInt32 _maxTimeMouseMove;
    UInt32 _maxTimeMouseWheel;
    UInt32 _maxTimeMouseDown;
    UInt32 _maxTimeMouseUp;
    UInt32 _maxTimeLeftMouseDoubleClick;
    UInt32 _maxTimeRightMouseDown;
    UInt32 _maxTimeRightMouseUp;
    UInt32 _maxTimeKeyboardDown;
    UInt32 _maxTimeKeyboardUp;
    
    uint32 _mouseMoveEventcount;
    uint32 _mouseMoveDiscardedEventCount;
}

@property (assign) IBOutlet NSWindow *window;

@property (nonatomic, retain, readonly) NSPersistentStoreCoordinator *persistentStoreCoordinator;
@property (nonatomic, retain, readonly) NSManagedObjectModel *managedObjectModel;
@property (nonatomic, retain, readonly) NSManagedObjectContext *managedObjectContext;

@property (nonatomic, retain) UDPClient *udpClient;
@property (nonatomic, retain) UDPClient *udpServer;

-(void)startClient;
-(void)startServer;
-(void)startMouseTracking;

//-(CGEventRef) myCGEventCallback: (CGEventTapProxy) proxy :(CGEventType) type :(CGEventRef) event :(void*) refcon;
CGEventRef myCGEventCallback(CGEventTapProxy proxy, CGEventType type, CGEventRef event, void *refcon);
- (IBAction)saveAction:sender;

@end
